import Vue from 'vue'
import Vuex from 'vuex'

import home from './modules/home'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    home: {
      namespaced: true,
      ...home
    }
  },
	state: {
	    hasLogin: false,
		user: {
			"id": 0,
			"name": "",
			"email": "",
			"phone": "",
			"avatar": "",
			"createime": 0,
			"state": 0,
			token: ""
		}
	},
	mutations: {
	    login(state, userName) {
	        state.user.name = userName || '新用户';
	        state.hasLogin = true;
	    },
	    logout(state) {
	        state.user.name = "";
	        state.hasLogin = false;
	    },
		setUserInfo(state, user) {
		    state.user = user;
		}
	}
})

export default store
